/**
* All Rights Reserved , Copyright (C) 2021 , 青岛鼎信通讯股份有限公司
*
* MpmProjectProductInfoService
* 产品信息表
*
* 修改纪录
* 2021-08-24 版本：1.0 chengengwei 创建。
* @version 版本：1.0
* @author 作者：chengengwei
* 创建日期：2021-08-24
*/
package com.topscomm.mpm.service.impl;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.topscomm.basic.BasicEntity;
import com.topscomm.cbo.pojo.CboItemDetailsEntity;
import com.topscomm.cbo.service.ICboItemDetailsService;
import com.topscomm.mpm.MpmSystemConst;
import com.topscomm.mpm.pojo.*;
import com.topscomm.mpm.service.IMpmProjectProductInfoService;
import com.topscomm.mpm.service.IMpmProjectService;
import com.topscomm.mpm.service.impl.auto.MpmProjectProductInfoServiceAuto;
import com.topscomm.pub.util.ConvertUtil;
import com.topscomm.pub.util.StringBufferProxy;
import com.topscomm.pub.util.StringUtil;
import com.topscomm.tap.common.ParameterCache;
import org.apache.commons.collections.ArrayStack;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;

import java.util.*;
import java.util.stream.Collectors;

@Service(value = "mpmProjectProductInfoService")
@Scope(value = "singleton")
public class MpmProjectProductInfoService extends MpmProjectProductInfoServiceAuto implements IMpmProjectProductInfoService {

    @Autowired
    private IMpmProjectService mpmProjectService;
    @Autowired
    private ICboItemDetailsService cboItemDetailsService;
    @Autowired
    private MpmProjectSaleService mpmProjectSaleService;
    @Autowired
    private MpmProjectChangeService mpmProjectChangeService;
    @Autowired
    private MpmProjectProductOutInfoService mpmProjectProductOutInfoService;
    @Autowired
    private MpmProjectProductInfoHisService mpmProjectProductInfoHisService;
    @Autowired
    private MpmProjectProductOutInfoHisService mpmProjectProductOutInfoHisService;
    /**
     * @author: chengengwei
     * @date: 2021-08-24
     * @description: 根据项目信息删除并新增产品信息
     * @modify:
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void removeAndAddRecord(Map<String, Object> paraMap) throws Exception {
        if (!paraMap.containsKey("productlist") && paraMap.get("productlist") == null) {
            return;
        }
        // 删除原有记录,生成新记录
        this.deleteByWhere(" projectid = '" + ConvertUtil.convertToString(paraMap.get("id")) + "' ");
        JSONArray jsonArray = (JSONArray) paraMap.get("productlist");
        List<Map> list = JSONObject.parseArray(jsonArray.toJSONString(), Map.class);
        if (CollectionUtil.isEmpty(list)) {
            return;
        }
        for (Map product : list) {
            MpmProjectProductInfoEntity mpmProjectProductInfoEntity = new MpmProjectProductInfoEntity();
            mpmProjectProductInfoEntity.convertFromMap(product);
            mpmProjectProductInfoEntity.setId(0L);
            mpmProjectProductInfoEntity.setProjectid(ConvertUtil.convertToLong(paraMap.get("id")));
            mpmProjectProductInfoEntity.setProjectname(ConvertUtil.convertToString(paraMap.get("projectname")));
            mpmProjectProductInfoEntity.setProjectcode(ConvertUtil.convertToString(paraMap.get("projectcode")));
            this.insert(mpmProjectProductInfoEntity);
        }
    }
    /**
     * @author: houyuhang
     * @date: 2023-04-24
     * @description: 变更完成后同步子表内容
     * @modify:
     */
    @Transactional(rollbackFor = Exception.class)
    public void updateFromHistory(long id) {
        // 获取变更记录
        StringBufferProxy sql = new StringBufferProxy();
        sql.appendSingle(" changeid = '{0}' ", id);
        List<MpmProjectProductInfoHisEntity> hisEntities = mpmProjectProductInfoHisService.queryByWhere(sql.toString());
        if (CollectionUtil.isEmpty(hisEntities)) {
            return;
        }
        // 变更完成后同步子表内容
        long projectid = hisEntities.get(0).getProjectid();
        this.deleteByWhere(" projectid = '" + projectid + "' ");
        for (MpmProjectProductInfoHisEntity tempHisEntity : hisEntities) {
            MpmProjectProductInfoEntity productEntity = new MpmProjectProductInfoEntity();
            productEntity.convertFromMap(tempHisEntity.convertToMap());
            productEntity.setId(0L);
            this.insert(productEntity);
        }
    }

    /**
     * @author: chengengwei
     * @date: 2021-08-24
     * @description: 查询LTC中产品信息
     * @modify:
     * @return
     */
    private List<? extends Map> queryProductInfo(List<String> products) throws Exception {
        // 查询本地数据库获取机会点信息
        if ("1".equals(ParameterCache.getValue("MPMQueryLTCByLocal"))) {
            Map<String, Object> params = new HashMap<>();
            params.put("productname", products.stream().collect(Collectors.joining("','", "'", "'")));
            return this.queryMap(params, "queryProductLine");
        } else {
            // 通过数据服务平台查询
            SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
            requestFactory.setConnectTimeout(2000);// 设置超时
            requestFactory.setReadTimeout(100000);// 读取超时时间
            RestTemplate restTemplate = new RestTemplate(requestFactory);
            HttpHeaders headers = new HttpHeaders();
            headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
            String token = ParameterCache.getValue("MPM_Token");
            String templateid = ParameterCache.getValue(MpmSystemConst.MPM_Query_ProductLine);
            headers.set("token", token);
            JSONObject map = new JSONObject();
            map.put("templateid", templateid);
            String url = ParameterCache.getValue("MPM_QueryUrl");
            JSONObject params = new JSONObject();
            params.put("productname", products.stream().collect(Collectors.joining("','", "'", "'")));
            map.put("paramsMap", params);
            // 设置分页查询
            map.put("pageNum", 1);
            map.put("pageSize", 100);

            HttpEntity<JSONObject> request = new HttpEntity<>(map, headers);
            ResponseEntity<JSONObject> response = restTemplate.postForEntity(url, request, JSONObject.class);

            if (response.getBody().getBooleanValue("success") == true) {
                JSONArray dataList = response.getBody().getJSONObject("result").getJSONArray("dataList");
                List<Map> list = JSONObject.parseArray(dataList.toJSONString(), Map.class);
                return list;
            } else {
                throw new Exception("保存信息失败，请联系管理员！");
            }
        }
    }
    /**
     * @author: houyuhang
     * @date: 2022-11-28
     * @description: 销售项目涉及产品范围json增加产品线编码
     * @modify:
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public void generateProductLineCode(Map<String, Object> paraMap) {
        StringBufferProxy sql = new StringBufferProxy();
        sql.appendSingle(" enabled = 1 and productrange is not null and productrange != '[]' ");
        List<MpmProjectEntity> mpmProjectEntities = mpmProjectService.queryByWhere(sql.toString());
        List<BasicEntity> basicEntities = new ArrayList<>();
        for (MpmProjectEntity mpmProjectEntity : mpmProjectEntities) {
            MpmProjectSaleEntity mpmProjectSaleEntity = mpmProjectSaleService.queryById(ConvertUtil.convertToString(mpmProjectEntity.getId()));
            String projectsource = mpmProjectSaleEntity.getProjectsource();
            List<Map> productList = JSONObject.parseArray(mpmProjectEntity.getProductrange(), Map.class);
            for (Map<String, Object> productMap : productList) {
                if (productMap.containsKey("line")) {
                    continue;
                }
                // 根据产品线名称对应产品线编码
                if (productMap.containsKey("productLine") && productMap.get("line") == null) {
                    String productLineName = ConvertUtil.convertToString(productMap.get("productLine"));
                    sql.clear();
                    sql.appendSingle(" itemid  = (select id from cboitems where code = 'ProductLine') and name = '{0}' ", productLineName);
                    List<CboItemDetailsEntity> cboItemDetailsEntities = cboItemDetailsService.queryByWhere(sql.toString());
                    if (!CollectionUtil.isEmpty(cboItemDetailsEntities)) {
                        productMap.put("line", cboItemDetailsEntities.get(0).getCode());
                        continue;
                    }
                }
                String productName = ConvertUtil.convertToString(productMap.get("productType"));
                // 机会点
                if ("2".equals(projectsource)) {
                    Map<String, Object> params = new HashMap<>();
                    params.put("productname", "'" + productName + "'");
                    List<Map<String, Object>> productLineList = this.queryMap(params, "queryProductLineEnabled");
                    // 根据产品名称找到产品线
                    if (!CollectionUtil.isEmpty(productLineList)) {
                        productMap.put("line", productLineList.get(0).get("PRODUCTLINECODE"));
                        continue;
                    } else {
                        List<Map<String, Object>> productLineListAll = this.queryMap(params, "queryProductLine");
                        if (!CollectionUtil.isEmpty(productLineListAll)) {
                            productMap.put("line", productLineListAll.get(0).get("PRODUCTLINECODE"));
                            continue;
                        }
                    }
                }
                // 线索
                if ("1".equals(projectsource)) {
                    sql.clear();
                    sql.appendSingle(" enabled = 1 and name = '{0}' and itemid = (select id from cboitems where code = 'ProductCatalog1') ", productName);
                    List<CboItemDetailsEntity> detailsEntities = cboItemDetailsService.queryByWhere(sql.toString());
                    if (!CollectionUtil.isEmpty(detailsEntities)) {
                        sql.clear();
                        sql.appendSingle(" SELECT * FROM MMSPRODUCTBASEINFO WHERE CATALOG1 = '{0}' AND ENABLED = 1 ", detailsEntities.get(0).getCode());
                        List<Map<String, Object>> mmsList = this.selectExecute(sql.toString());
                        if (!CollectionUtil.isEmpty(mmsList)) {
                            productMap.put("line", mmsList.get(0).get("productline"));
                            continue;
                        } else {
                            sql.clear();
                            sql.appendSingle(" SELECT * FROM MMSPRODUCTBASEINFO WHERE CATALOG1 = '{0}' ", detailsEntities.get(0).getCode());
                            List<Map<String, Object>> mmsListAll = this.selectExecute(sql.toString());
                            if (!CollectionUtil.isEmpty(mmsListAll)) {
                                productMap.put("line", mmsListAll.get(0).get("productline"));
                                continue;
                            }
                        }
                    }
                }
                // 载波
                if (",宽带HPLC+RF双模,宽带HPLC载波模块,载波-大功率中继器（宽带）HPLC,载波-大功率中继器(宽带)HPLC,宽带HPLC+RF双模三相,宽带HPLC载波二型采集器,宽带HPLC+HRF双模,".contains("," + productMap.get("productType") + ",")) {
                    productMap.put("line", "1");
                    continue;
                }
                // 量测
                if (",国网C级D级智能表（协议库存省招）,国网20规范三相表,".contains("," + productMap.get("productType") + ",")) {
                    productMap.put("line", "2");
                    continue;
                }
                // 终端
                if (",智能融合终端,".contains("," + productMap.get("productType") + ",")) {
                    productMap.put("line", "3");
                    continue;
                }
                // 电测仪器
                if (",低压台区相位识别仪,现场校验仪用电检查仪,".contains("," + productMap.get("productType") + ",")) {
                    productMap.put("line", "5");
                    continue;
                }
            }
            mpmProjectEntity.setProductrange(JSONArray.toJSONString(productList));
            basicEntities.add(mpmProjectEntity);
        }
        mpmProjectService.updateBatch(basicEntities);
    }
    /**
     * @author: houyuhang
     * @date: 2022-11-28
     * @description: 销售项目涉及产品范围json增加产品线编码
     * @modify:
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public List<String> queryProductLineNo(Map<String, Object> paraMap) {
        StringBufferProxy sql = new StringBufferProxy();
        sql.appendSingle(" enabled = 1 and productrange is not null and productrange != '[]' ");
        List<MpmProjectEntity> mpmProjectEntities = mpmProjectService.queryByWhere(sql.toString());
        Set<String> resSet = new HashSet<>();
        List<String> list = new ArrayList<>();
        for (MpmProjectEntity mpmProjectEntity : mpmProjectEntities) {
            List<Map> productList = JSONObject.parseArray(mpmProjectEntity.getProductrange(), Map.class);
            for (Map<String, Object> productMap : productList) {
                if (!productMap.containsKey("line") && !productMap.containsKey("productLine")) {
                    resSet.add(ConvertUtil.convertToString(productMap.get("productType")));
                }
            }
        }
        list.addAll(resSet);
        return list;
    }
    /**
     * @author: houyuhang
     * @date: 2022-11-28
     * @description: 销售项目涉及产品范围json增加产品线编码
     * @modify:
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public void generateProductLineCodeChange(Map<String, Object> paraMap) {
        StringBufferProxy sql = new StringBufferProxy();
        sql.appendSingle(" enabled = 1 and productrange2 is not null and productrange2 != '[]' ");
        List<MpmProjectChangeEntity> mpmProjectEntities = mpmProjectChangeService.queryByWhere(sql.toString());
        List<BasicEntity> basicEntities = new ArrayList<>();
        for (MpmProjectChangeEntity mpmProjectEntity : mpmProjectEntities) {
            String projectsource = mpmProjectEntity.getProjectsource2();
            List<Map> productList = JSONObject.parseArray(mpmProjectEntity.getProductrange2(), Map.class);
            for (Map<String, Object> productMap : productList) {
                if (productMap.containsKey("line")) {
                    continue;
                }
                // 根据产品线名称对应产品线编码
                if (productMap.containsKey("productLine") && productMap.get("line") == null) {
                    String productLineName = ConvertUtil.convertToString(productMap.get("productLine"));
                    sql.clear();
                    sql.appendSingle(" itemid  = (select id from cboitems where code = 'ProductLine') and name = '{0}' ", productLineName);
                    List<CboItemDetailsEntity> cboItemDetailsEntities = cboItemDetailsService.queryByWhere(sql.toString());
                    if (!CollectionUtil.isEmpty(cboItemDetailsEntities)) {
                        productMap.put("line", cboItemDetailsEntities.get(0).getCode());
                        continue;
                    }
                }
                String productName = ConvertUtil.convertToString(productMap.get("productType"));
                // 机会点
                if ("2".equals(projectsource)) {
                    Map<String, Object> params = new HashMap<>();
                    params.put("productname", "'" + productName + "'");
                    List<Map<String, Object>> productLineList = this.queryMap(params, "queryProductLineEnabled");
                    // 根据产品名称找到产品线
                    if (!CollectionUtil.isEmpty(productLineList)) {
                        productMap.put("line", productLineList.get(0).get("PRODUCTLINECODE"));
                        continue;
                    } else {
                        List<Map<String, Object>> productLineListAll = this.queryMap(params, "queryProductLine");
                        if (!CollectionUtil.isEmpty(productLineListAll)) {
                            productMap.put("line", productLineListAll.get(0).get("PRODUCTLINECODE"));
                            continue;
                        }
                    }
                }
                // 线索
                if ("1".equals(projectsource)) {
                    sql.clear();
                    sql.appendSingle(" enabled = 1 and name = '{0}' and itemid = (select id from cboitems where code = 'ProductCatalog1') ", productName);
                    List<CboItemDetailsEntity> detailsEntities = cboItemDetailsService.queryByWhere(sql.toString());
                    if (!CollectionUtil.isEmpty(detailsEntities)) {
                        sql.clear();
                        sql.appendSingle(" SELECT * FROM MMSPRODUCTBASEINFO WHERE CATALOG1 = '{0}' AND ENABLED = 1 ", detailsEntities.get(0).getCode());
                        List<Map<String, Object>> mmsList = this.selectExecute(sql.toString());
                        if (!CollectionUtil.isEmpty(mmsList)) {
                            productMap.put("line", mmsList.get(0).get("productline"));
                            continue;
                        } else {
                            sql.clear();
                            sql.appendSingle(" SELECT * FROM MMSPRODUCTBASEINFO WHERE CATALOG1 = '{0}' ", detailsEntities.get(0).getCode());
                            List<Map<String, Object>> mmsListAll = this.selectExecute(sql.toString());
                            if (!CollectionUtil.isEmpty(mmsListAll)) {
                                productMap.put("line", mmsListAll.get(0).get("productline"));
                                continue;
                            }
                        }
                    }
                }
                // 载波
                if (",宽带HPLC+RF双模,宽带HPLC载波模块,载波-大功率中继器（宽带）HPLC,载波-大功率中继器(宽带)HPLC,宽带HPLC+RF双模三相,宽带HPLC载波二型采集器,宽带HPLC+HRF双模,".contains("," + productMap.get("productType") + ",")) {
                    productMap.put("line", "1");
                    continue;
                }
                // 量测
                if (",国网C级D级智能表（协议库存省招）,国网20规范三相表,".contains("," + productMap.get("productType") + ",")) {
                    productMap.put("line", "2");
                    continue;
                }
                // 终端
                if (",智能融合终端,".contains("," + productMap.get("productType") + ",")) {
                    productMap.put("line", "3");
                    continue;
                }
                // 电测仪器
                if (",低压台区相位识别仪,现场校验仪用电检查仪,".contains("," + productMap.get("productType") + ",")) {
                    productMap.put("line", "5");
                    continue;
                }
            }
            mpmProjectEntity.setProductrange2(JSONArray.toJSONString(productList));
            basicEntities.add(mpmProjectEntity);
        }
        mpmProjectChangeService.updateBatch(basicEntities);
    }
    /**
     * @author: houyuhang
     * @date: 2022-11-28
     * @description: 销售项目涉及产品范围json增加产品线编码立项变更
     * @modify:
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public List<String> queryProductLineNoChange(Map<String, Object> paraMap) {
        StringBufferProxy sql = new StringBufferProxy();
        sql.appendSingle(" enabled = 1 and productrange2 is not null and productrange2 != '[]' ");
        List<MpmProjectChangeEntity> mpmProjectEntities = mpmProjectChangeService.queryByWhere(sql.toString());
        Set<String> resSet = new HashSet<>();
        List<String> list = new ArrayList<>();
        for (MpmProjectChangeEntity mpmProjectEntity : mpmProjectEntities) {
            List<Map> productList = JSONObject.parseArray(mpmProjectEntity.getProductrange2(), Map.class);
            for (Map<String, Object> productMap : productList) {
                if (!productMap.containsKey("line") && !productMap.containsKey("productLine")) {
                    resSet.add(ConvertUtil.convertToString(productMap.get("productType")));
                }
            }
        }
        list.addAll(resSet);
        return list;
    }
    /**
     * @author: houyuhang
     * @date: 2023-04-20
     * @description: 销售项目将主表productrange字段同步到productinfo子表,将productoutrange字段同步到productoutinfo子表
     * @modify:
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public void insertProductInfoSubTable(Map<String, Object> paraMap) {
        // 删除表中原有的数据
        this.deleteByWhere(" 1=1 ");
        mpmProjectProductOutInfoService.deleteByWhere(" 1=1 ");
        // 导入内外部产品子表数据
        StringBufferProxy sql = new StringBufferProxy();
        sql.appendSingle(" MpmProject.enabled = 1 ");
        List<Map<String, Object>> mpmProjectList = mpmProjectService.queryMapByWhere(sql.toString(), "queryPolymarizationMapByWhere");
        for (Map<String, Object> mpmProjectMap : mpmProjectList) {
            this.insertSubProductInfo(mpmProjectMap);
            mpmProjectProductOutInfoService.insertSubProductOutInfo(mpmProjectMap);
        }
    }
    /**
     * @author: houyuhang
     * @date: 2023-05-16
     * @description: 销售项目同步内部外部产品历史表
     * @modify:
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public void insertProductForHis(Map<String, Object> paraMap) {
        // 删除表中原有的数据
        mpmProjectProductInfoHisService.deleteByWhere(" 1=1 ");
        mpmProjectProductOutInfoHisService.deleteByWhere(" 1=1 ");
        // 导入内外部产品历史子表数据
        List<Map<String, Object>> changeList = mpmProjectService.selectExecute(" select mpmprojectchange.*, mpmproject.id as projectid from mpmprojectchange left join mpmproject on mpmprojectchange.projectcode2 = mpmproject.projectcode ");
        for (Map<String, Object> changeMap : changeList) {
            mpmProjectProductInfoHisService.insertSubProductInfo(changeMap);
            mpmProjectProductOutInfoHisService.insertSubProductOutInfo(changeMap);
        }
    }
    /**
     * @author: houyuhang
     * @date: 2023-04-20
     * @description: 将主表productrange字段同步到productinfo子表
     * @modify:
     */
    @Transactional(rollbackFor = Exception.class)
    public void insertSubProductInfo(Map<String, Object> mpmProjectMap) {
        // 获取产品信息
        List<Map> list = JSONObject.parseArray(ConvertUtil.convertToString(mpmProjectMap.get("productrange")), Map.class);
        if (CollectionUtil.isEmpty(list)) {
            return;
        }
        for (Map tempMap : list) {
            Map<String, Object> sqlMap = new HashMap<>();
            sqlMap.put("projectsource", ConvertUtil.convertToString(mpmProjectMap.get("projectsource")));
            sqlMap.put("productname", ConvertUtil.convertToString(tempMap.get("productType")));
            List<Map<String, Object>> productcodeList = this.queryMap(sqlMap, "queryProductCode");
            MpmProjectProductInfoEntity productInfoEntity = new MpmProjectProductInfoEntity();
            productInfoEntity.setFund(ConvertUtil.convertToBigDecimal(tempMap.get("productMoney")));
            productInfoEntity.setProductlinecode(ConvertUtil.convertToString(tempMap.get("line")));
            productInfoEntity.setProductlinename(ConvertUtil.convertToString(tempMap.get("productLine")));
            if (!CollectionUtil.isEmpty(productcodeList)) {
                productInfoEntity.setProductcode(ConvertUtil.convertToString(productcodeList.get(0).get("code")));
            } else {
                // 根据业务方提供的对应关系赋值编码
                productInfoEntity.setProductcode(this.getProductCodeOther(ConvertUtil.convertToString(mpmProjectMap.get("projectsource")), ConvertUtil.convertToString(tempMap.get("productType"))));
            }
            productInfoEntity.setProductname(ConvertUtil.convertToString(tempMap.get("productType")));
            productInfoEntity.setProjectcode(ConvertUtil.convertToString(mpmProjectMap.get("projectcode")));
            productInfoEntity.setProjectname(ConvertUtil.convertToString(mpmProjectMap.get("projectname")));
            productInfoEntity.setProjectid(ConvertUtil.convertToLong(mpmProjectMap.get("id")));
            this.insert(productInfoEntity);
        }
    }
    /**
     * @author: houyuhang
     * @date: 2023-05-17
     * @description:
     * @modify:
     */
    public String getProductCodeOther(String projectsource, String productname) {
        if (MpmSystemConst.MpmProjectSource.lead.equals(projectsource)) {
            // 线索对应产品大类
            switch (productname) {
                case "低压台区相位识别仪":
                    return "88";
                case "国网20规范三相表":
                    return "125";
                case "国网C级D级智能表（协议库存省招）":
                    return "140";
                case "宽带HPLC+HRF双模":
                    return "107";
                case "宽带HPLC+RF双模":
                    return "105";
                case "宽带HPLC载波二型采集器":
                    return "9";
                case "宽带HPLC载波模块":
                    return "8";
                case "智能融合终端":
                    return "33";
                case "现场校验仪用电检查仪":
                    return "131";
                case "载波-大功率中继器（宽带）HPLC":
                    return "12";
            }
        } else {
            // 机会点对应产品中类
            switch (productname) {
                case "低压台区相位识别仪":
                    return "142";
                case "国网20规范C级D级智能表（协议库存省招）":
                    return "203";
                case "国网20规范三相表":
                    return "185";
                case "国网C级/D级智能表（协议库存省招）":
                    return "203";
                case "宽带HPLC+HRF双模II型":
                    return "217";
                case "宽带HPLC+HRF双模单相":
                    return "162";
                case "宽带HPLC+HRF双模路由":
                    return "164";
                case "宽带HPLC+HRF双模三相":
                    return "163";
                case "宽带HPLC+RF双模单相":
                    return "159";
                case "宽带HPLC+RF双模路由":
                    return "161";
                case "宽带HPLC+RF双模三相":
                    return "160";
                case "现场校验仪用电检查仪":
                    return "194";
                case "载波-大功率中继器(宽带)HPLC":
                    return "25";
                case "智能融合终端":
                    return "60";
                case "中压线变关系分析机（CT）":
                    return "88";
                case "中压线变关系分析机（GC）":
                    return "89";
                case "定制化小型化V2模块":
                    return "166";
            }
        }
        return "";
    }
}
